const { defineConfig } = require('@vue/cli-service')
const path = require('path');
const { DefinePlugin } = require('webpack');
module.exports = defineConfig({
  transpileDependencies: true,
  publicPath : '/',
  pluginOptions : {
    "style-resources-loader" : {
      preProcessor : "less",
      patterns : [
        path.resolve(__dirname , "src/styles/theme.less")
      ]
    }
  },
  configureWebpack : {
    plugins : [
      new DefinePlugin({
        '__VUE_PROD_HYDRATION_MISMATCH_DETAILS__' : JSON.stringify(true)
      })
    ]
  },
  devServer : {
    client : {
      overlay : false
    },
    // historyApiFallback : true,
    proxy : {
      '/authentication-server/': {
        target: 'http://10.44.52.113:23001/',
        pathRewrite: {
          "^/authentication-server" : ''
        }
      },
      '/account-server/': {
        target: 'http://10.44.52.113:23000/',
        pathRewrite : {
          "^/account-server" : ''
        }
      }
    },
    headers : {
      'Access-Control-Allow-Origin': '*'
    }
  },
  css : {
    loaderOptions : {
      less : {
        lessOptions : {
          javascriptEnabled: true
        }
      }
    }
    // 会影响css样式热更新
    // extract : {
    //   ignoreOrder : true
    // }
  },
  chainWebpack : config => {
    config.output
      .filename('js/[name].[fullhash:8].js')
      .chunkFilename('chunks/[name].[fullhash:8].js')
    config.plugin('html').tap(args => {
      args[0].title = 'xxx系统';
      return args;
    });
  }
})
